package correct.day26;

import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] ch = in.next().toCharArray();
        int min = -1;
        for(int i = 0; i < ch.length; i++) {
            int len = lenBack(ch, i);
            if(len > 1 && len % 2 == 0) {
                min = 2;
            } else if (len > 1 && len % 2 == 1){
                min = 3;
            }
        }
        System.out.println(min);
    }

    public static int lenBack(char[] ch, int index) {
        // 奇数
        int len1 = 1;
        int left = index - 1;
        int right = index + 1;
        while(left >= 0 && right < ch.length && left < right) {
            if(ch[left] != ch[right]) {
                break;
            }
            left--;
            right++;
            len1 += 2;
        }
        // 偶数
        int len2 = 0;
        left = index;
        right = index + 1;
        while(left >= 0 && right < ch.length && left < right) {
            if(ch[left] != ch[right]) {
                break;
            }
            left--;
            right++;
            len2 += 2;
        }
        if(len2 > 1) {
            return len2;
        } else {
            return len1;
        }
    }
}
